Move HTTP integration configuration to the UI#170321
Closed
MindFreeze wants to merge 7 commits into
Closed
Conversation
Contributor
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
12 tasks
8 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR begins migrating the HTTP integration’s configuration from configuration.yaml to a UI-managed configuration, backed by persistent storage and exposed via admin-only WebSocket commands.
Changes:
- Add a dedicated
Store(http.config) for user-managed HTTP configuration and wire it into the HTTP integration startup flow. - Introduce admin-only WebSocket commands to read/update the stored HTTP config.
- Add new Repairs issues/translations and expand test coverage for storage migration and the WebSocket API.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/http/__init__.py |
Loads/persists user config from storage, imports YAML on first run, falls back on invalid stored config, registers WS commands. |
homeassistant/components/http/storage.py |
Adds the http.config Store wrapper and serialization helper for persisted config. |
homeassistant/components/http/websocket_api.py |
Implements http/config/get and http/config/update admin WebSocket commands. |
homeassistant/components/http/issue.py |
Adds Repairs issue helpers and defines the deprecation break version. |
homeassistant/components/http/strings.json |
Adds translations for the new Repairs issues. |
tests/components/http/test_storage.py |
Tests YAML→store import, defaults initialization, stored-over-YAML precedence, and invalid stored fallback behavior. |
tests/components/http/test_websocket_api.py |
Tests WebSocket get/update behavior and admin authorization. |
tests/components/http/test_init.py |
Updates expectations for new deprecation issue creation when YAML http: config is present. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…rt-failure repair
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+41
to
+49
| def async_get_store(hass: HomeAssistant) -> HttpConfigStore: | ||
| """Return the user-config Store, private to the integration.""" | ||
| return HttpConfigStore( | ||
| hass, | ||
| USER_CONFIG_STORAGE_VERSION, | ||
| USER_CONFIG_STORAGE_KEY, | ||
| private=True, | ||
| atomic_writes=True, | ||
| ) |
Comment on lines
+52
to
+64
| store = async_get_store(hass) | ||
| existing = await store.async_load() or {} | ||
| merged = {**existing, **msg["config"]} | ||
|
|
||
| try: | ||
| validated = HTTP_SCHEMA(merged) | ||
| except vol.Invalid as err: | ||
| connection.send_error(msg["id"], websocket_api.ERR_INVALID_FORMAT, str(err)) | ||
| return | ||
|
|
||
| stored = to_stored(cast(dict[str, Any], validated)) | ||
| await store.async_save(stored) | ||
| connection.send_result(msg["id"], {"config": stored}) |
Member
|
Closing in favour of #171177 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Moves the HTTP integration's configuration out of
configuration.yamland into a UI form under Settings > System > Network. Existing YAML is imported on first start and a repair issue prompts the user to remove thehttp:block. Stored config that fails validation at startup falls back to safe defaults so users aren't locked out.This is the first step toward dropping the hard dependency on port 8123 and supporting alternative network setups (ports 80/443, multiple instances, etc.).
Implementation
Store(http.config) for the user-managed config, kept separate from the existingSTORAGE_KEY = "http"recovery snapshot.http/config/getandhttp/config/updateWebSocket commands (admin-only).HTTP_SCHEMA, persist, raisedeprecated_yaml. On subsequent starts, the store wins over YAML and the repair stays until YAML is removed. Stored config that no longer validates falls back to defaults with ahttp_failed_to_startrepair.breaks_in_ha_version="2027.6.0"Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: